/**
 * 
 */
package com.nh.action;

import org.apache.commons.lang.StringUtils;

import com.nh.common.DictionaryKey;

/**
 * 项目名称：NotoginsengManage
 * 
 * 类名称：SecurityAction
 * 
 * 类描述： 安全设置
 * 
 * 创建人：李兴建
 * 
 * E-mail:lxj08193@163.com
 * 
 * 创建时间：2012-11-9 下午09:30:47
 * 
 * 修改人：李兴建
 * 
 * 修改时间：2012-11-9 下午09:30:47
 * 
 * 修改备注：
 * 
 * @version
 */
public class SecurityAction extends BaseAction {

	// 0:删除到已过滤回收站 1：直接删除 2：替换关键字为"???"号
	private int keyWordSetType;

	private String keyWord;

	private int verificationTag;
	

	/**
	 * 关键字设置页面
	 * 
	 * @return
	 */
	public String keyWordSetPage() {
		if (StringUtils.isNotEmpty(this.getDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD_SETTYPE))) {
			keyWordSetType = Integer.parseInt(this.getDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD_SETTYPE));
		}
		if (StringUtils.isNotEmpty(this.getDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD))) {
			keyWord = this.getDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD);
		}

		this.setTitle("关键字过滤设置");
		return "keyWordSetPage";
	}

	/**
	 * 保存
	 * 
	 * @return
	 */
	public String keyWordSave() {
		try {
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD, keyWord);
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD_SETTYPE, keyWordSetType + "");
			this.addFieldError("errorInfo", "保存成功");
		} catch (Exception e) {
			this.addFieldError("errorInfo", "保存失败");
			e.printStackTrace();
		}

		return keyWordSetPage();
	}

	/**
	 * 审核设置
	 * 
	 * @return
	 */
	public String verificationSetPage() {
		if (StringUtils.isNotEmpty(this.getDictionaryValue(DictionaryKey.DICTIONARY_KEY_VERIFICATION))) {
			verificationTag = Integer.parseInt(this.getDictionaryValue(DictionaryKey.DICTIONARY_KEY_VERIFICATION));
		}
		this.setTitle("审核设置");
		return "verificationSetPage";
	}

	/**
	 * 保存
	 * 
	 * @return
	 */
	public String verificationSave() {
		try {
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_VERIFICATION, verificationTag+"");
			this.addFieldError("errorInfo", "保存成功");
		} catch (Exception e) {
			this.addFieldError("errorInfo", "保存失败");
			e.printStackTrace();
		}

		return verificationSetPage();
	}

	/**
	 * @return the keyWord
	 */
	public String getKeyWord() {
		return keyWord;
	}

	/**
	 * @param keyWord
	 *            the keyWord to set
	 */
	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	/**
	 * @return the verificationTag
	 */
	public Integer getVerificationTag() {
		return verificationTag;
	}

	/**
	 * @param verificationTag
	 *            the verificationTag to set
	 */
	public void setVerificationTag(Integer verificationTag) {
		this.verificationTag = verificationTag;
	}

	/**
	 * @return the keyWordSetType
	 */
	public int getKeyWordSetType() {
		return keyWordSetType;
	}

	/**
	 * @param keyWordSetType
	 *            the keyWordSetType to set
	 */
	public void setKeyWordSetType(int keyWordSetType) {
		this.keyWordSetType = keyWordSetType;
	}


}
